from math import log10

def digits(n):
    """Returns the decimal digits of n as a list."""
    return [int(d) for d in str(n)]

def nrDigits(n):
    """Returns the nr of decimal digits needed to represent n."""
    return 1 + int(log10(n))
    
def rdigits(digits):
    """Given a list of decimal digits, return the corresponding number."""
    n = 0
    for d in digits:
        n *= 10
        n += d
        
    return n

def reverse(n):
    return int(str(n)[::-1])

def sumOfDigits(n):
    """Calculates the sum of the (decimal) digits of n."""
    return sum(digits(n))

def hasUniqueDigits(n):
    """Verifies that the decimal representation of n has unique digits."""
    s = str(n)
    return all(1 == s.count(c) for c in s)
    
def isPandigital3(a,b,c):
    s = str(a) + str(b) + str(c)
    return len(s)==9 and "123456789".strip(s)==""

def isPandigital(a):
    s = str(a)
    return len(s)==9 and "123456789".strip(s)==""
